package com.ymttest.database.sqlwapper.shenqisettlement;

import java.util.HashMap;
import java.util.List;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.shenqisettlement.CompanyInfo;

public class CompanyInfoWrapper {
	
	SqlManager manager;

	public CompanyInfoWrapper() {
		manager = new SqlManager("shenqisettlement");
	}

	@SuppressWarnings("unchecked")
	public CompanyInfo selectByPrimaryKey(Long id) {

		CompanyInfo companyInfo = new CompanyInfo();
		List<CompanyInfo> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.shenqisettlement.CompanyInfoMapper.selectByPrimaryKey",
						id);
		manager.commit();

		if (result.size() > 0) {
			companyInfo = result.get(0);
		}

		return companyInfo;
	}
	
	@SuppressWarnings("unchecked")
	public CompanyInfo selectByUserIdAndAccountType(long userId, int accountType) {

		HashMap<String, Object> map = new HashMap<String, Object>();
		
		map.put("userId", userId);
		map.put("accountType", accountType);
		
		CompanyInfo companyInfo = new CompanyInfo();
		List<CompanyInfo> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.shenqisettlement.CompanyInfoMapper.selectByUserIdAndAccountType",
						map);
		manager.commit();

		if (result.size() > 0) {
			companyInfo = result.get(0);
		}

		return companyInfo;
	}
	
	public static void main(String[] args) {
		
		CompanyInfoWrapper wrapper = new CompanyInfoWrapper();
		
		System.out.println(wrapper.selectByUserIdAndAccountType(500044527L, 1).getCompany_code());
	}
}
